<?php

namespace app\chats\controller;

use think\Db;
use think\Request;
use think\Session;

class Index extends Common
{
    public function index()
    {
        $request = Request::instance();

        header('location:' . $request->domain() . '/chat');
    }

    public function out()
    {
        $admin = Session::get('admin', 'mmjtChats');

        if ($admin) {
            Db::name('user')->where(['id' => $admin['id']])->update(['chats_admin_status' => 0]);
        }

        session(null, 'mmjtChats');

        return json(['code' => 200, 'msg' => '退出成功']);
    }
}
